#include "TIMER.H"
TIMER_STR TIMER_EA_SEND,TIMER_RUN,TIMER_STOP,TIMER_cycle1;
struct tm *stmU;
uint32_t G_time_stamp;

void TIMER_INI(void)
{
	TIMER_EA_SEND.interval=10;//m
	TIMER_cycle1.interval=15;//m
}

void stamp2realtime(uint32_t stamp)
{
	struct tm temptm;
	temptm=*(localtime(&stamp));
	G_REG[H_RmtTime_Y].value=temptm.tm_year-100;
	G_REG[H_RmtTime_M].value=temptm.tm_mon+1;
	G_REG[H_RmtTime_D].value=temptm.tm_mday;
	G_REG[H_RmtTime_h].value=temptm.tm_hour;
	G_REG[H_RmtTime_m].value=temptm.tm_min;
	G_REG[H_RmtTime_s].value=temptm.tm_sec;	
	//G_REG[H_SynTime].value=1;
	//WRITE_TIME();
}
void stamp2planstop(uint32_t stamp)
{
	struct tm temptm;
	temptm=*(localtime(&stamp));
	G_REG[PLAN_STOP_TIM_Y].value=temptm.tm_year-100;
	G_REG[PLAN_STOP_TIM_M].value=temptm.tm_mon+1;
	G_REG[PLAN_STOP_TIM_D].value=temptm.tm_mday;
	G_REG[PLAN_STOP_TIM_h].value=temptm.tm_hour;
	G_REG[PLAN_STOP_TIM_m].value=temptm.tm_min;
	G_REG[PLAN_STOP_TIM_s].value=temptm.tm_sec;	
	RUN_STAMP=time2stamp(G_REG[PLAN_START_TIM_Y].value,G_REG[PLAN_START_TIM_M].value,
											G_REG[PLAN_START_TIM_D].value,G_REG[PLAN_START_TIM_h].value,
											G_REG[PLAN_START_TIM_m].value,G_REG[PLAN_START_TIM_s].value);

	STOP_STAMP=time2stamp(G_REG[PLAN_STOP_TIM_Y].value,G_REG[PLAN_STOP_TIM_M].value,
											G_REG[PLAN_STOP_TIM_D].value,G_REG[PLAN_STOP_TIM_h].value,
											G_REG[PLAN_STOP_TIM_m].value,G_REG[PLAN_STOP_TIM_s].value);

}
void stamp2planstart(uint32_t stamp)
{
	struct tm temptm;
	temptm=*(localtime(&stamp));
	G_REG[PLAN_START_TIM_Y].value=temptm.tm_year-100;
	G_REG[PLAN_START_TIM_M].value=temptm.tm_mon+1;
	G_REG[PLAN_START_TIM_D].value=temptm.tm_mday;
	G_REG[PLAN_START_TIM_h].value=temptm.tm_hour;
	G_REG[PLAN_START_TIM_m].value=temptm.tm_min;
	G_REG[PLAN_START_TIM_s].value=temptm.tm_sec;
}